package com.caigou.comm.base.glide

import android.content.Context
import com.bumptech.glide.Glide
import com.bumptech.glide.Registry
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.module.AppGlideModule
import com.caigou.comm.base.network.ServiceCreators
import java.io.InputStream

/**
 * @author #Suyghur.
 * Created on 2021/11/26
 */
@GlideModule
class ImageAppModule : AppGlideModule() {

    override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
        super.registerComponents(context, glide, registry)
        // 替换底层网络框架为okhttp3
        registry.replace(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(ServiceCreators.httpClient))
    }
}